package com.egg.ylt.adapter;

import android.content.Context;
import android.view.View;

import com.egg.ylt.R;
import com.egg.ylt.Utils.Constants;
import com.egg.ylt.pojo.GrowUpRecordEntity;
import com.yonyou.framework.library.adapter.rv.CommonAdapter;
import com.yonyou.framework.library.adapter.rv.ViewHolder;
import com.yonyou.framework.library.common.utils.ScreenUtil;
import com.yonyou.framework.library.common.utils.StringUtil;
import com.yonyou.framework.library.common.utils.ToastUtil;
import com.yonyou.framework.library.dialog.AlertDialog;
import com.yonyou.framework.library.eventbus.EventCenter;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by lijiateng on 2019/1/19.
 */

public class ADA_GrowUpRecord extends CommonAdapter<GrowUpRecordEntity.ListBean> {

    public ADA_GrowUpRecord(Context context) {
        super(context);
    }

    @Override
    protected int itemLayoutId() {
        return R.layout.item_grow_up_record;
    }

    @Override
    protected void convert(ViewHolder holder, final GrowUpRecordEntity.ListBean item, final int position) {

        // 日期
        holder.setText(R.id.tv_date, item.getDate() + " " + item.getWeek());

        // 身高
        holder.setText(R.id.tv_height, item.getHeight() == 0 ? "--" : StringUtil.getString(item.getHeight()));

        // 体重
        holder.setText(R.id.tv_weight, item.getWeight() == 0 ? "--" : StringUtil.getString(item.getWeight()));

        // more
        holder.setOnClickListener(R.id.iv_more, new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                int size = mDatas.size();
                item.setPosition(position);
                EventBus.getDefault().post(new EventCenter(Constants.MODIFY_RECORD_EVENT, item));

            }
        });


    }

}
